package schoolWork.work02;

public class Car {
    //定义属性
    private double gas;
    private double gasConsum;

    //定义方法
    public Car(double gasConsum){
        this.gasConsum = gasConsum;
    }

    public void addGas(double gas){
        this.gas = gas;
    }

    public double gasGasInTank(){
        return gas;
    }

    public void drive(double distance){
        gas = gas - (distance * gasConsum / 100.0);
        System.out.println("开车了" + distance + "公里");
    }
}
